package com.rayo.accesscontrollercopy.model.db.dao;


import com.rayo.accesscontrollercopy.model.db.DbHelp;
import com.rayo.accesscontrollercopy.model.db.bean.ReaderData;

import java.util.List;

/**
 * Created by yanghaojie on 16/7/26.
 */
public class ReaderDataImpl implements ReaderDataDao {
    @Override
    public List<ReaderData> findAll() {
        return DbHelp.getQueryAll(ReaderData.class);
    }

    @Override
    public ReaderData findFirst() {
        List<ReaderData> list = findAll();
        if (null == list || 0 == list.size())
            return null;
        else
            return list.get(0);
    }

    @Override
    public void addReader(ReaderData readerData) {
        DbHelp.insert(readerData);
    }

    @Override
    public void updateReader(ReaderData readerData) {
        DbHelp.update(readerData);
    }

    @Override
    public void deleteAll() {
        DbHelp.deleteAll(ReaderData.class);
    }
}
